<style lang="scss">
.createOrder {
  .el-form {
    text-align: center;
    height: 70vh;
    overflow: auto;

    .el-input, .el-textarea {
      width: 250px !important;
    }

    .el-textarea__inner, .el-input__inner {
      background-color: #FAFBFC;
      width: 250px !important;
    }

    .el-input__inner::-webkit-input-placeholder {
      color: #97A4BB;
      font-size: 14px;
    }

    .el-textarea__inner::-webkit-input-placeholder {
      color: #97A4BB;
      font-size: 14px;
      font-weight: 600;
    }

    .el-textarea__inner {
      color: #606266;
      height: 550px;
    }
  }
}
</style>
<template>
  <el-dialog title="创建订单" :visible.sync="createShow" append-to-body width="450px" class="createOrder">
    <el-form inline ref="createForm" :model="createForm">

      <el-form-item label="渠道名称" prop="salesChannel"
                    :rules="{required:true,message:'销售渠道不能为空',trigger:'change'}">
        <el-select v-model="createForm.salesChannel" placeholder="请选择渠道" filterable>
          <el-option v-for="(item, indx) in saleChannelList" :key="indx" :label="item.dictLabel"
                     :value="item.dictCode"/>
        </el-select>
      </el-form-item>

      <el-form-item label="提货金额" prop="saleAmount"
                    :rules="{required:true,message:'提货金额不能为空',trigger:'blur'}">
        <el-input type="number" v-model="createForm.saleAmount" placeholder="请输入渠道名称"/>
      </el-form-item>

      <el-form-item label="异常类型" prop="problemType"
                    :rules="{required:true,message:'异常类型不能为空',trigger:'change'}">
        <el-select v-model="createForm.problemType" placeholder="请选择异常类型">
          <el-option label="已售找回" value="SoldRecovered"/>
          <el-option label="已售异常" value="SoldException"/>
        </el-select>
      </el-form-item>

      <el-form-item label="游戏品类" prop="dictCodeId">
        <el-select v-model="createForm.dictCodeId" placeholder="请选择游戏品类" filterable>
          <el-option v-for="item in gameList" :key="item.dictCode" :label="item.dictLabel"
                     :value="item.dictCode"/>
        </el-select>
      </el-form-item>

      <el-form-item label="游戏账号" prop="account" :rules="{required:true,message:'游戏账号不能为空',trigger:'blur'}">
        <el-input v-model="createForm.account" placeholder="请输入游戏账号"/>
      </el-form-item>

      <el-form-item label="回收金额" prop="recycleAmount"
                    :rules="{required:true,message:'回收金额不能为空',trigger:'blur'}">
        <el-input v-model="createForm.recycleAmount" type="number" placeholder="请输入回收金额"/>
      </el-form-item>

      <el-form-item label="回收渠道" prop="recycleChannelId"
                    :rules="{required:true,message:'回收渠道不能为空',trigger:'change'}">
        <el-select v-model="createForm.recycleChannelId" placeholder="请选择回收渠道" filterable>
          <el-option v-for="item in recycleChannelList" :key="item.dictCode" :label="item.dictLabel"
                     :value="item.dictCode"/>
        </el-select>
      </el-form-item>

      <el-form-item label="回收编号" prop="orderNumber"
                    :rules="{required:true,message:'回收编号不能为空',trigger:'blur'}">
        <el-input v-model="createForm.orderNumber" placeholder="请输入回收编号"/>
      </el-form-item>

      <el-form-item label="异常原因" prop="abnormityReason"
                    :rules="{required:true,message:'异常原因不能为空',trigger:'blur'}">
        <el-input type="textarea" v-model="createForm.abnormityReason" :rows="20" placeholder="请输入异常原因"/>
      </el-form-item>
    </el-form>

    <div slot="footer" class="dialog-footer">
      <el-button @click="createShow = false">取 消</el-button>
      <el-button type="primary" @click="handleSubmit">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
import {getSupplier} from "@/api/business/api";
import {addAbnormalApi} from "@/api/business/abnormal";

export default {
  props: {
    gameList: {
      type: Array,
      default: []
    },
    saleChannelList: {
      type: Array,
      default: []
    }
  },
  data() {
    return {
      suppliersList: [],//供应商类型
      recycleChannelList: [],//回收渠道
      createShow: false,
      createForm: {
        salesChannel: '',
        dictCodeId: '',//游戏品类
        supplier: '',
        saleAmount: '',//销售金额
        problemType: '',//异常类型
        account: '',//游戏账号
        recycleAmount: '',//回收金额
        recycleChannelName: '',//回收渠道
        orderNumber: '',//回收编号
        abnormityReason: `一：此账号您在手期间是否出售、以及换绑过、给过他人验证码.密码：

二：此账号您之前绑定的电话是多少：

三：此账号您最后一次登陆的时间以及地址：

四：此账号的防沉迷实名您是否修改成为了您自己的：

五：此账号您自己是否提交过申诉：

六：你登入手机型号是什么

以上六条请如实告知，如有别的信息也请如实说，如果没有如实告知，我们核实到有上述情况将不予归还账号及提供赔付，如查到恶意骗保所购买账号将全部失去包赔，经核实如有欺骗行为 直接按 诈骗罪 起诉 ！！！`
      }
    }
  },
  created() {
// 获取供应商
    getSupplier().then(res => {
      this.suppliersList = res.data;
    })

    //查询回收渠道字典
    this.getDicts('recycle_channel').then(res => {
      this.recycleChannelList = res.data
    })
  },
  methods: {

    // 打开弹框
    handleOpen() {
      this.createShow = true;
    },

    handleClose() {
      this.createShow = false;
    },

    // 提交
    handleSubmit() {
      this.$refs.createForm.validate(valid => {
        if (valid) {
          addAbnormalApi(this.createForm).then(res => {
            if (res.code == 200) {
              this.$message.success("创建成功！");
              this.createShow = false;
            } else {
              this.$message.error(res.message);
            }
          })
        }
      })
    }
  }
}
</script>
